<template>
  <div class="uploadimg">
    <el-upload
      class="avatar-uploader"
      :action="uploadHeadImage"
      :show-file-list="false"
      :on-success="handleAvatarSuccess"
      :before-upload="beforeAvatarUpload">
      <img v-if="imageUrl" :src="imageUrl" class="avatar" :style="styleys">
      <i v-else class="el-icon-plus avatar-uploader-icon" :style="styleys"></i>
    </el-upload>
  </div>
</template>
<script type="text/babel">
// @ is an alias to /src
import { uploadHeadImage } from '../assets/js/domains'

export default {
  name: 'upload',
  components: {},
  data: function () {
    return {
      imageUrl: '',
      uploadHeadImage: uploadHeadImage
    }
  },
  props: {
    styleys: {
      default: function () {
        return {}
      }
    }
  },
  computed: {},
  created: function () {
  },
  mounted: function () {
  },
  methods: {
    handleAvatarSuccess: function () {
    },
    beforeAvatarUpload: function () {
    }
  }
}
</script>
<style lang="less">
  .uploadimg {
    display: inline-block;

    .avatar-uploader .el-upload {
      border: 1px dashed #d9d9d9;
      border-radius: 6px;
      cursor: pointer;
      position: relative;
      overflow: hidden;
    }

    .avatar-uploader .el-upload:hover {
      border-color: #409EFF;
    }

    .avatar-uploader-icon {
      font-size: 28px;
      color: #8c939d;
      width: 178px;
      height: 178px;
      line-height: 178px;
      text-align: center;
    }

    .avatar {
      width: 178px;
      height: 178px;
      display: block;
    }
  }
</style>
